"use strict";
function ownKeys(t, e) {
  var r = Object.keys(t);
  if (Object.getOwnPropertySymbols) {
    var a = Object.getOwnPropertySymbols(t);
    e &&
      (a = a.filter(function (e) {
        return Object.getOwnPropertyDescriptor(t, e).enumerable;
      })),
      r.push.apply(r, a);
  }
  return r;
}
function _objectSpread(t) {
  for (var e = 1; e < arguments.length; e++) {
    var r = null != arguments[e] ? arguments[e] : {};
    e % 2
      ? ownKeys(Object(r), !0).forEach(function (e) {
          _defineProperty(t, e, r[e]);
        })
      : Object.getOwnPropertyDescriptors
      ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(r))
      : ownKeys(Object(r)).forEach(function (e) {
          Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(r, e));
        });
  }
  return t;
}
function _defineProperty(e, t, r) {
  return (
    t in e
      ? Object.defineProperty(e, t, {
          value: r,
          enumerable: !0,
          configurable: !0,
          writable: !0,
        })
      : (e[t] = r),
    e
  );
}
function _typeof(e) {
  return (_typeof =
    "function" == typeof Symbol && "symbol" == typeof Symbol.iterator
      ? function (e) {
          return typeof e;
        }
      : function (e) {
          return e &&
            "function" == typeof Symbol &&
            e.constructor === Symbol &&
            e !== Symbol.prototype
            ? "symbol"
            : typeof e;
        })(e);
}
!(function (t) {
  var e = {
    init: function () {
        e.passwordVisibilityToggle(),
        e.labelUpdate(),
        e.radioTabs(),
        e.formValidation(),
        e.inputFormatter(),
        e.bsAccordion(),
        e.multilevelDropdown(),
        e.offcanvas(),
        e.priceSwitch(),
        e.rangeSlider(),
        e.viewSwitcher(),
        e.checkboxToggleClass(),
        e.masterCheckbox()
    },
    passwordVisibilityToggle: function () {
      for (
        var r = document.querySelectorAll(".cs-password-toggle"),
          e = function (e) {
            var t = r[e].querySelector(".form-control");
            r[e].querySelector(".cs-password-toggle-btn").addEventListener(
              "click",
              function (e) {
                "checkbox" === e.target.type &&
                  (e.target.checked
                    ? (t.type = "text")
                    : (t.type = "password"));
              },
              !1
            );
          },
          t = 0;
        t < r.length;
        t++
      )
        e(t);
    },
    labelUpdate: function () {
      for (
        var e = document.querySelectorAll("[data-label]"), t = 0;
        t < e.length;
        t++
      )
        e[t].addEventListener("change", function () {
          var e = this.dataset.label;
          try {
            document.getElementById(e).textContent = this.value;
          } catch (e) {
            (e.message = "Cannot set property 'textContent' of null"),
              console.error(
                "Make sure the [data-label] matches with the id of the target element you want to change text of!"
              );
          }
        });
    },
    radioTabs: function () {
      for (
        var e = document.querySelectorAll('[data-toggle="radioTab"]'), t = 0;
        t < e.length;
        t++
      )
        e[t].addEventListener("click", function () {
          var e = this.dataset.target;
          document
            .querySelector(this.dataset.parent)
            .querySelectorAll(".radio-tab-pane")
            .forEach(function (e) {
              e.classList.remove("active");
            }),
            document.querySelector(e).classList.add("active");
        });
    },
    formValidation: function () {
      window.addEventListener(
        "load",
        function () {
          var e = document.getElementsByClassName("needs-validation");
          Array.prototype.filter.call(e, function (t) {
            t.addEventListener(
              "submit",
              function (e) {
                !1 === t.checkValidity() &&
                  (e.preventDefault(), e.stopPropagation()),
                  t.classList.add("was-validated");
              },
              !1
            );
          });
        },
        !1
      );
    },
    inputFormatter: function () {
      var e = document.querySelectorAll("[data-format]");
      if (0 !== e.length)
        for (var t = 0; t < e.length; t++) {
          var r = e[t].dataset.format,
            a = e[t].dataset.blocks,
            n = e[t].dataset.delimiter;
          switch (
            ((a = void 0 !== a ? a.split(" ").map(Number) : ""),
            (n = void 0 !== n ? n : " "),
            r)
          ) {
            case "card":
              new Cleave(e[t], { creditCard: !0 });
              break;
            case "cvc":
              new Cleave(e[t], { numeral: !0, numeralIntegerScale: 3 });
              break;
            case "date":
              new Cleave(e[t], { date: !0, datePattern: ["m", "y"] });
              break;
            case "date-long":
              new Cleave(e[t], {
                date: !0,
                delimiter: "-",
                datePattern: ["Y", "m", "d"],
              });
              break;
            case "time":
              new Cleave(e[t], { time: !0, datePattern: ["h", "m"] });
              break;
            case "custom":
              new Cleave(e[t], { delimiter: n, blocks: a });
              break;
            default:
              console.error(
                "Sorry, your format " +
                  r +
                  " is not available. You can add it to the theme object method - inputFormatter in src/js/theme.js or choose one from the list of available formats: card, cvc, date, date-long, time or custom."
              );
          }
        }
    },
    bsAccordion: function () {
      for (
        var n = document.querySelectorAll(".accordion-alt"),
          o = function (e, t) {
            e.classList.add(t);
          },
          s = function (e, t) {
            e.classList.remove(t);
          },
          e = function (e) {
            for (
              var t = n[e].querySelectorAll('[data-toggle="collapse"]'),
                r = n[e].querySelectorAll(".card"),
                a = 0;
              a < t.length;
              a++
            )
              t[a].addEventListener("click", function () {
                for (
                  var e = this.parentNode.parentNode.parentNode, t = 0;
                  t < r.length;
                  t++
                )
                  s(r[t], "card-active");
                (this.classList.contains("collapsed")
                  ? this.classList.contains("custom-control")
                    ? s
                    : o
                  : this.classList.contains("custom-control")
                  ? o
                  : s)(e, "card-active");
              });
          },
          t = 0;
        t < n.length;
        t++
      )
        e(t);
    },
    multilevelDropdown: function () {
      t(".dropdown-menu [data-toggle='dropdown']").on("click", function (e) {
        e.preventDefault(),
          e.stopPropagation(),
          t(this).siblings().toggleClass("show"),
          t(this).next().hasClass("show") ||
            t(this)
              .parents(".dropdown-menu")
              .first()
              .find(".show")
              .removeClass("show"),
          t(this)
            .parents("li.nav-item.dropdown.show")
            .on("hidden.bs.dropdown", function () {
              t(".dropdown-submenu .show").removeClass("show");
            });
      });
    },
    offcanvas: function () {
      for (
        var e = document.querySelectorAll('[data-toggle="offcanvas"]'), t = 0;
        t < e.length;
        t++
      )
        e[t].addEventListener("click", function (e) {
          e.preventDefault(),
            document
              .getElementById(e.currentTarget.dataset.offcanvasId)
              .classList.toggle("show");
        });
    },
    priceSwitch: function () {
      var o = document.querySelectorAll(".cs-pricing-wrap");
      if (null !== o)
        for (
          var e = function (e) {
              function t() {
                if (a.checked) {
                  r.parentNode.classList.add("cs-price-switch-on");
                  for (var e = 0; e < n.length; e++)
                    n[e].innerHTML = n[e].dataset.newPrice;
                } else {
                  r.parentNode.classList.remove("cs-price-switch-on");
                  for (var t = 0; t < n.length; t++)
                    n[t].innerHTML = n[t].dataset.currentPrice;
                }
              }
              var r = o[e].querySelector(".custom-switch"),
                a = r.querySelector('input[type="checkbox"]'),
                n = o[e].querySelectorAll(".cs-price");
              t(),
                a.addEventListener("change", function () {
                  t();
                });
            },
            t = 0;
          t < o.length;
          t++
        )
          e(t);
    },
    rangeSlider: function () {
      for (
        var o = document.querySelectorAll(".cs-range-slider"),
          e = function (e) {
            var t = o[e].querySelector(".cs-range-slider-ui"),
              a = o[e].querySelector(".cs-range-slider-value-min"),
              n = o[e].querySelector(".cs-range-slider-value-max"),
              r = {
                dataStartMin: parseInt(o[e].dataset.startMin, 10),
                dataStartMax: parseInt(o[e].dataset.startMax, 10),
                dataMin: parseInt(o[e].dataset.min, 10),
                dataMax: parseInt(o[e].dataset.max, 10),
                dataStep: parseInt(o[e].dataset.step, 10),
              };
            noUiSlider.create(t, {
              start: [r.dataStartMin, r.dataStartMax],
              connect: !0,
              step: r.dataStep,
              pips: { mode: "count", values: 5 },
              tooltips: !0,
              range: { min: r.dataMin, max: r.dataMax },
              format: {
                to: function (e) {
                  return "$" + parseInt(e, 10);
                },
                from: function (e) {
                  return Number(e);
                },
              },
            }),
              t.noUiSlider.on("update", function (e, t) {
                var r = e[t];
                (r = r.replace(/\D/g, "")),
                  t ? (n.value = Math.round(r)) : (a.value = Math.round(r));
              }),
              a.addEventListener("change", function () {
                t.noUiSlider.set([this.value, null]);
              }),
              n.addEventListener("change", function () {
                t.noUiSlider.set([null, this.value]);
              });
          },
          t = 0;
        t < o.length;
        t++
      )
        e(t);
    },
    viewSwitcher: function () {
      var e = document.querySelectorAll("[data-view]");
      if (0 < e.length)
        for (var t = 0; t < e.length; t++)
          e[t].addEventListener("click", function (e) {
            var t = this.dataset.view;
            r(t), "#" === this.getAttribute("href") && e.preventDefault();
          });
      var r = function (e) {
        for (
          var t = document.querySelector(e),
            r = t.parentNode.querySelectorAll(".cs-view"),
            a = 0;
          a < r.length;
          a++
        )
          r[a].classList.remove("show");
        t.classList.add("show");
      };
    },
    checkboxToggleClass: function () {
      var e = document.querySelectorAll("[data-checkbox-toggle-class]");
      if (0 !== e.length)
        for (var t = 0; t < e.length; t++)
          e[t].addEventListener("change", function () {
            var e = document.querySelector(this.dataset.target),
              t = this.dataset.checkboxToggleClass;
            this.checked ? e.classList.add(t) : e.classList.remove(t);
          });
    },
    masterCheckbox: function () {
      var e = document.querySelectorAll("[data-master-checkbox-for]");
      if (0 !== e.length)
        for (var t = 0; t < e.length; t++)
          e[t].addEventListener("change", function () {
            var e = document
              .querySelector(this.dataset.masterCheckboxFor)
              .querySelectorAll('input[type="checkbox"]');
            if (this.checked)
              for (var t = 0; t < e.length; t++)
                (e[t].checked = !0),
                  e[t].dataset.checkboxToggleClass &&
                    document
                      .querySelector(e[t].dataset.target)
                      .classList.add(e[t].dataset.checkboxToggleClass);
            else
              for (var r = 0; r < e.length; r++)
                (e[r].checked = !1),
                  e[r].dataset.checkboxToggleClass &&
                    document
                      .querySelector(e[r].dataset.target)
                      .classList.remove(e[r].dataset.checkboxToggleClass);
          });
    },
  };
  e.init();
})(jQuery);
